﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Collections;
using Webchatting.Common;
using Webchatting.Dal;

public partial class server_DeleteFriends : System.Web.UI.Page
{
    
    public static ArrayList arrFRUIds = new ArrayList();
    public static ArrayList arrFRURemarkNames = new ArrayList();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnGetFriend_Click(object sender, EventArgs e)
    {
        OperationFriends OFriends = new OperationFriends();
        FormsIdentity id = (FormsIdentity)User.Identity;
        string getFriends = OFriends.GetFriend(id.Ticket.UserData.Split('@')[0], arrFRUIds, arrFRURemarkNames);

        ltlResult.Text = "<b>搜索结果：</b><br/>" + getFriends;
        ltlText.Text = "<b>请选择要删除好友的ID：</b>";
        ddlAddFriend.Visible = true;
        btnDeleteFriend.Visible = true;

        while (ddlAddFriend.Items.Count > 0)
        {
            ddlAddFriend.Items.RemoveAt(0);
        }

        for (int i = 0; i < arrFRUIds.Count; i++)
        {
            ddlAddFriend.Items.Add(new ListItem((string)arrFRUIds[i], (string)arrFRUIds[i]));
        }
    }
    protected void btnDeleteFriend_Click(object sender, EventArgs e)
    {
        OperationFriends OFriend2 = new OperationFriends();

        int selected = ddlAddFriend.SelectedIndex;
        FormsIdentity id2 = (FormsIdentity)User.Identity;

        try
        {
            OFriend2.DeleteFriend(id2.Ticket.UserData.Split('@')[0], arrFRUIds[selected].ToString());
                

            Response.Write("<script>alert('删除好友成功!');window.parent.location.href='RUIndex.aspx';</script>");
        }
        catch
        {
            Javascript.GoHistory(-1, "已经删除，请不要重复删除！", Page);
        }
    }
   
}
